package org.open.cobertura.logging;

import java.text.SimpleDateFormat;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

/**
 * 日志格式化
 */
public class CoberturaLoggingFormatter extends Formatter {
    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    @Override
    public String format(LogRecord record) {
        StringBuilder sb = new StringBuilder();
        String dataFormat = this.sdf.format(Long.valueOf(record.getMillis()));
        sb.append(dataFormat).append(" ");
        sb.append(record.getLevel()).append(" ");
        sb.append(record.getSourceClassName()).append(" ");
        sb.append(record.getSourceMethodName()).append(" ");
        sb.append(record.getMessage()).append("\n");
        return sb.toString();
    }
}
